package qnb._common.easyui;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.List;

/**
 * @author huangxin
 * @date 2019/5/20-10:16
 */
public class MenuVO implements Cloneable{
    private Integer id;
    private Integer pid;
    private String name;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Boolean open;//是否开启树状菜单
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String file;//url
    @JsonInclude(JsonInclude.Include.NON_EMPTY)//不转换为json
    private List<MenuVO> children;

    public List<MenuVO> getChildren() {
        if (children==null){
            children = new ArrayList<>();
        }
        return children;
    }

    public void setChildren(List<MenuVO> children) {

        this.children = children;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getOpen() {
        return open;
    }

    public void setOpen(Boolean open) {
        this.open = open;
    }

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }

    public MenuVO() {
    }

    public MenuVO(Integer id, Integer pid, String name, Boolean open, String file) {
        this.id = id;
        this.pid = pid;
        this.name = name;
        this.open = open;
        this.file = file;
    }

    public MenuVO copy(){
        try {
            MenuVO menuVO = (MenuVO) this.clone();
            menuVO.setChildren(null);
            return menuVO;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
